<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		
		<script>
			if("WebSocket" in window){
				alert("您的浏览器支持WebSocket");
				
				//打开一个websocket连接
				var ws = new WebSocket("xxxxxxxxxxxxxx");
				 ws.onopen = function(){
					 //已连接
				 }
				 ws.onmessage = function(evt){
					 var msg = evt.data;
					 console.log("服务器: "+msg)
				 }
				 ws.onclose = function(){
					 console.log("已关闭连接")
				 }
			}else{
				alert('您的浏览器不支持WebSocket')
			}
		</script>
	</body>
</html>